home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Graphics⁄Sound / Fudd Source / Fudd ƒ / MSG Shell ƒ / msg integrity.c < prev    next >
Text File  |  1994-02-07  |  2KB  |  82 lines

  1. /**********************************************************************\
  2.  
  3. File:        msg integrity.c
  4.  
  5. Purpose:    This module implements a quick-and-dirty integrity check;
  6.             compare the resource fork and map length to stored values.
  7.             (Drop the completed application on "Prepare" to store
  8.             these values in the right place.)
  9.  
  10. Fudd -=- convert text to Elmer Fudd talk
  11. Copyright ©1994, Mark Pilgrim
  12.  
  13. This program is free software; you can redistribute it and/or modify
  14. it under the terms of the GNU General Public License as published by
  15. the Free Software Foundation; either version 2 of the License, or
  16. (at your option) any later version.
  17.  
  18. This program is distributed in the hope that it will be useful,
  19. but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21. GNU General Public License for more details.
  22.  
  23. You should have received a copy of the GNU General Public License
  24. along with this program in a file named "GNU General Public License".
  25. If not, write to the Free Software Foundation, 675 Mass Ave,
  26. Cambridge, MA 02139, USA.
  27.  
  28. \**********************************************************************/
  29.  
  30. #include "msg integrity.h"
  31. #include "msg graphics.h"
  32. #include "msg dialogs.h"
  33. #include "program globals.h"
  34.  
  35. void DoIntegrityCheck(void)
  36. {
  37.     int                thisFile;
  38.     long            count;
  39.     long            resDataLength, checkData;
  40.     long            resMapLength, checkMap;
  41.     Boolean            problem;
  42.     
  43.     problem=FALSE;
  44.     FlushVol(0L, 0);
  45.     OpenRF(CurApName, 0, &thisFile);
  46.     if (!problem)
  47.     {
  48.         SetFPos(thisFile, 1, 8L);
  49.         count=4L;
  50.         problem=(FSRead(thisFile, &count, (Ptr)(&resDataLength))!=noErr);
  51.     }
  52.     if (!problem)
  53.     {
  54.         SetFPos(thisFile, 1, 12L);
  55.         count=4L;
  56.         problem=(FSRead(thisFile, &count, (Ptr)(&resMapLength))!=noErr);
  57.     }
  58.     if (!problem)
  59.     {
  60.         SetFPos(thisFile, 1, 144L);
  61.         count=4L;
  62.         problem=(FSRead(thisFile, &count, (Ptr)(&checkData))!=noErr);
  63.     }
  64.     if (!problem)
  65.     {
  66.         SetFPos(thisFile, 1, 148L);
  67.         count=4L;
  68.         problem=(FSRead(thisFile, &count, (Ptr)(&checkMap))!=noErr);
  69.     }
  70.     
  71.     if (!problem)
  72.         problem=((resDataLength!=checkData) || (resMapLength!=checkMap));
  73.  
  74.     if (problem)
  75.     {
  76.         ParamText(APPLICATION_NAME, "\p", "\p", "\p");
  77.         PositionDialog('ALRT', integrityCheckFailAlert);
  78.         StopAlert(integrityCheckFailAlert,0L);
  79.         ExitToShell();
  80.     }
  81. }
  82.